package actions;

import java.util.ArrayList;

import javax.ejb.EJB;

import beans.SearchBean;
import beans.SearchManager;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import entities.Item;

public class DisplayItemsAdminAction extends ActionSupport {

	private ArrayList<Item> resultItemsAdmin = null;

	@EJB
	private SearchManager searchMgr = new SearchBean();

	public String execute() {
		Integer userIdObj = (Integer) ActionContext.getContext().getSession()
				.get("userId");
		if (userIdObj == null) {
			this.addActionError("UserID is null");
			return ERROR;
		}

		resultItemsAdmin = searchMgr.getAllItems();
		return "success";
	}

	public void setResultItemsAdmin(ArrayList<Item> resultItemsAdmin) {
		this.resultItemsAdmin = resultItemsAdmin;
	}

	public ArrayList<Item> getResultItemsAdmin() {
		return resultItemsAdmin;
	}

}
